# a = 10
# b = 20
# c = 'abc'
# print('a = %d b = %d c = %s' % (a,b,c))
#
# e = '高尔基'
# print('今天是{0}的生日，{0}特地去买了生日蛋糕'.format('高尔基'))
#
# print(5//3)
# print(4**4)
#
# list = [1,2,3,4,5,6]
# print(list)
# # str  = str.join(list)
# print(str)
import random
import time
# if None:
#     print(True)
# else:
#     print(False)

# a = range(1,10)
# print(a)
# str = '1,2,3,4,5,'
# str = str.strip(',')
# print(str)
# for _ in a:
#     print(_,end=',')
#
# len = a.count(1)
# print(len)
#
# # 初始化计数器
# i = 0
# # 编写循环条件
# while i < 5:
#     if i == 2:
#         i+=1
#         continue
#     print('老婆大人，我错了')
#
# # 更新计数器
#     i += 1
# # 循环结束后，女朋友就原谅我了
# else:
#     print('好开森，女朋友原谅我了...')

# str1 = 'itheima'
# for i in str1:
#     if i == 'e':
#         print('遇e不打印')
#         break
#     print(i)
# else:
#     print('循环正常结束之后执行的代码')

# str1 = 'itheima'
# for i in str1:
#     if i == 'e':
#         print('遇e不打印')
#         continue
#     print(i)
# else:
#     print('循环正常结束之后执行的代码')

import turtle

# turtle.pencolor('red')
# for i in range(5):
#     turtle.forward(100)
#     turtle.right(144)
# time.sleep(3)

# for i in range(6):
#     color = '#'
#     color += ''.join(str(i) for i in random.sample(range(0,9),6))
#     turtle.pencolor(color)
#     turtle.forward(100)
#     turtle.right(60)
# time.sleep(3)

# for i in range(6):
#     color = '#'
#     R = random.randint(0,255)
#     G = random.randint(0,255)
#     B = random.randint(0,255)
#     color += f'{R}{G}{B}'
#     turtle.pencolor(color)
#     turtle.forward(100)
#     turtle.right(60)
# time.sleep(3)

# a = 1
# b = 2
# c = 3
# print(f'{a:.1f},{b:.2f},{c:.3f}')

# filename = 'avatar.png'
# # 获取点号的索引下标
# index = 6
# # 使用切片截取文件的文件
# name = filename[:index]
# print(f'上传文件的名称：{name}')
#
# # 使用切片截取文件的后缀
# postfix = filename[index + 1:]
# print(f'上传文件的后缀：{postfix}')

# str1 = 'apple, banana, orange'
# # 判断apple是否出现在字符串str1中
# print(str1.index('apple'))
# # print(str1.index('pineapple'))
# print(str1.title())

# str1 = 'hello linux and hello linux'
# # 把字符串中所有linux字符替换为python
# print(str1.replace('linux', 'python'))
# # 把字符串中的第一个linux进行替换为python
# print(str1.replace('linux', 'python', 2))
# # 把and字符串替换为&&
# print(str1.replace('and', '&&'))
# index = str1.find("d")
# print(str1[:index+1] + str1[index+1:].replace('linux', 'python'))

# str1 = 'hello linux and hello linux'
# list = str1.split(' ')
# print(list)
# print(' '.join(list))
# print(str1.startswith('h'))
# print(str1.endswith('x'))

# # 1、查找某个元素在列表中出现的位置（索引下标）
# list1 = ['apple', 'banana', 'pineapple']
# print(list1.index('apple'))  # 0
# # print(list1.index('peach'))  # 报错
#
# # 2、count()方法：统计元素在列表中出现的次数
# list2 = ['刘备', '关羽', '张飞', '关羽', '赵云']
# # 统计一下关羽这个元素在列表中出现的次数
# print(list2.count('关羽'))

# # 3、in方法和not in方法（黑名单系统）
# list3 = ['192.168.1.15', '10.1.1.100', '172.35.46.128']
# if '10.1.1.100' in list3:
#     print('黑名单IP，禁止访问')
# else:
#     print('正常IP，访问站点信息')


# if 1 in range(10):
#     print('666')
#
# if 11 not in range(10):
#     print('888')

# list = [1,2,3,4,5,6]
# print(type(list))
# print(list)
# list.reverse()
# print(list)
# list.remove(6)
# print(list)
# print(list.count(1))
# list.sort()
# print(list)
# list.append(7)
# print(list)
# list.extend([8,9])
# print(list)
# list.extend(['老师'])
# print(list)

# names = ['孙悟空', '唐僧', '猪八戒']
# names[1] = '老师'
# print(names)
# names.sort()
# print(names)
# names.sort(reverse=True)
# print(names)
# # del names[1]
# dl = names.remove('猪八戒')
# print(dl)
# dl = names.pop()
# print(dl)
# dl = names.clear()
# print(dl)
# print(names)

# # 在列表的尾部追加一个元素"沙僧"
# names.extend(['沙僧'])
# names.append(['老师','学生'])
# # 打印列表
# print(names)
# names.insert(0,'老师')
# print(names)


# tuple = ()
# print(type(tuple))

students = [['张三', '李四'], ['王五', '赵六'], ['田七', '孙八']]

# students = [x,y,z]
# students[0] == ['张三', '李四']
# students[0][1] = '王五'

# 访问李四
# print(students[0][1])
# 嵌套列表进行遍历，获取每个班级的学员信息
# for i in students:
#     for j in i:
#         print(j,end=',')

# a = (10)
# b = ('a')
# c = (True)
# d = ([1,2])
# e = ((1,2))
# f = ({1,2})
# g = ({'1':1,'2':2})
# print(type(a))
# print(type(b))
# print(type(c))
# print(type(d))
# print(type(e))
# print(type(f))
# print(type(g))


# a = (10,)
# b = ('a',)
# c = (True,)
# d = ([1,2],)
# e = ((1,2),)
# f = ({1,2},)
# g = ({'1':1,'2':2},)
# print(type(a))
# print(type(b))
# print(type(c))
# print(type(d))
# print(type(e))
# print(type(f))
# print(type(g))

# tuple = (1,2,3,4)
# del tuple[1]
# print(tuple)

# list = [1,2,3,4,5,6]
# print(len(list))
# list = (1,2,3,4,5,6)
# print(len(list))
# print(list.count(1))
# print(list[1])
# print(len("asdsag"))
# str = "asdsag"
# print(str.count('a'))

# list = []
# list = list({1,2,3})
# print(list)
# print(type(list))
# #
# # tuple = ()
# tuple = tuple((1,2,3))
# print(tuple)
# print(type(tuple))

# dict = {1:1,2:2,3:3}
# print(dict)

# 1、定义一个空字典
# person = {}
# 2、向字典中添加数据
# person['name'] = '刘备'
# person['age'] = 40
# person['address'] = '蜀中'
# person['address'] = '拉拉'
# del person['address']
# 3、使用print方法打印person字典
# print(person)
# if 'name' in person.keys():
#     print(person['name'])
# if '刘备' in person.values():
#     print(person['name'])
# for _ in person.keys():
#     print(_)
#
# for _ in person.values():
#     print(_)

# person.clear()
# print(person)

# # 1、定义一个字典
# cat = {'name':'Tom', 'age':5,'gender':'security', 'address':'美国纽约'}
# # 2、获取字典的相关信息
# name = cat.get('name')
# age = cat.get('age')
# gender = cat.get('gender', 'male')  # get(key, 默认值)
# address = cat.get('address')
# print(f'姓名：{name}，年龄：{age}，性别：{gender}，住址：{address}')

# 1、定义一个字典
person = {'name': '貂蝉', 'age': 18, 'mobile': '13765022249'}
# 2、调用items方法获取数据，dict_items([('name', '貂蝉'), ('age', 18), ('mobile', '13765022249')])
# print(person.items())
# 3、结合for循环对字典中的数据进行遍历
# for key, value in person.items():
#     print(f'{key}：{value}')
# for k,v in person.items():
#     print(f'{k}：{v}')


# students = [{'name':'刘备', 'age':18, 'mobile': '10086'}, {'name':'关羽', 'age':17, 'mobile': '10000'}, {'name':'张飞', 'age':16, 'mobile': '10010'}]
# for i in students:
#     item = '['
#     for k,v in i.items():
#        item += f'{k}:{v},'
#     item = item.strip(',') + ']'
#     print(item)

# set = {}

# set = set()
# print(type(set))

# 定义一个集合：集合中存在相同的数据
# s2 = {'刘备', '曹操', '孙权', '曹操'}
# print(s2)
# print(type(s2))

# students = set()
# students.add('李哲')
# students.add('刘毅')
# print(students)

# students = set()
# list1 = ['刘备', '关羽', '赵云']
# students.update(list1)
# print(students)

# students = set()
# students.add('刘德华')
# students.add('黎明')
# students.add('天亮')
# students.add('傻子')
# 使用update新增元素
# students.update('蔡徐坤')
# students.update([4,5,6])
# students.update((11,22,33))
# students.update({'a','b','c','c'})
# students.update({0:'e',1:'f',2:'g',3:'h'})
# print(students)
# s = students.remove('刘德华1')
# print(s)
# s = students.discard('1')
# print(s)
# s = students.pop()
# print(s)
# print(students)
# students = {'刘德华', '黎明', '蔡', '徐', '坤'}

# 定义一个set集合
s1 = {'刘帅', '英标', '高源'}
# 判断刘帅是否在s1集合中
# if '刘帅' in s1:
#     print('刘帅在s1集合中')
# else:
#     print('刘帅没有出现在s1集合中')
#
# if '刘帅' not in s1:
#     print('刘帅bu在s1集合中')
# else:
#     print('刘帅在s1集合中')

# for i in s1:
#     print(i)

# # 求集合中的交集、并集、差集
# s1 = {'刘备', '关羽', '张飞', '貂蝉'}
# s2 = {'袁绍', '吕布', '曹操', '貂蝉'}
#
# # 求两个集合中的交集
# print(s1 & s2)
#
# # 求两个集合中的并集
# print(s1 | s2)
#
# # 求连个集合中的差集
# print(s1 - s2)
# print(s2 - s1)

# # 1、+加号，代表两个序列之间的连接与整合
# str1 = 'hello'
# str2 = 'world'
# print(str1 + str2)
#
# # 2、定义两个列表，对其数据进行整合
# list1 = ['刘备', '关羽']
# list2 = ['诸葛亮', '赵云']
# print(list1 + list2)
#
# # 3、定义两个元组，对其数据进行整合
# tuple1 = (10, 20, 30)
# tuple2 = (30, 40)
# print(tuple1 + tuple2)
